#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e6 + 5;

int n, m;
int tr[N][26], ed[N], fail[N], tot;
int newnode() { return ++tot; }
void insert(string s) {
  int p = 0;
  for (char c : s) {
    int ch = c - 'a';
    if (!tr[p][ch]) tr[p][ch] = newnode();
    p = tr[p][ch];
  }
  ed[p]++;
}
void build_ac() {
  queue<int> q;
  rep(i, 0, 25) if (tr[0][i]) q.push(tr[0][i]);
  while (q.size()) {
    int p = q.front();
    q.pop();
    rep(i, 0, 25) {
      if (tr[p][i]) {
        q.push(tr[p][i]);
        fail[tr[p][i]] = tr[fail[p]][i];
      } else {
        tr[p][i] = tr[fail[p]][i];
      }
    }
  }
}
int search(string s) {
  int res = 0;
  int p = 0;
  for (char c : s) {
    int q = tr[p][c - 'a'];
    while (q && ed[q] >= 0) {
      res += ed[q];
      ed[q] = -1;
      q = fail[p];
    }
    p = tr[p][c - 'a'];
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) {
    string s;
    cin >> s;
    insert(s);
  }
  build_ac();
  string t;
  cin >> t;
  cout << search(t);
  return 0;
}